home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / dev / basic / ace24dist.lha / ace24.lha / SUBmods / Complex / fractal.b < prev    next >
Text File  |  1996-09-10  |  787b  |  54 lines

  1. #include "complex.h"
  2.  
  3. DECLARE STRUCT Complex a,b,c,t,e,*d
  4.  
  5. t->real = 1.0 : t->imag = 0.0
  6.  
  7. const win = 400
  8.  
  9. window 1,,(0,0)-(win,win),16
  10.  
  11. on break goto quit
  12.  
  13. right  =  4.0
  14. left   = -2.0
  15. top    =  2.0
  16. bottom = -4.0
  17.  
  18. depth = 50
  19.  
  20. dx = (right-left)/win
  21. dy = (bottom-top)/win
  22.  
  23. break on
  24.  
  25. for y = 1 to win
  26.   b->imag = top + y*dy
  27.   for x = 1 to win
  28.     b->real = left + x*dx
  29.  
  30.     a->real = 0 : a->imag = 0
  31.     r! = 0 : ctr = 0
  32.  
  33.     while r! < 100 and ctr < depth
  34.       MulComp(a,a,c)
  35.       DivComp(t,b,e)
  36.       AddComp(c,e,a)
  37.       r! = (a->real * a->real) + (a->imag * a->imag)
  38.       ++ctr
  39.     wend
  40.  
  41.     color 1
  42.     if ctr < depth then color 2
  43.     if ctr< depth and abs(a->real) > 5 and abs(a->imag) > 5 then color 3
  44.     pset (x,y)
  45.   next
  46. next
  47.  
  48. locate 0,0
  49. input a$
  50.  
  51. quit:
  52.   window close 1
  53.   end
  54.